package com.lee.boot.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lee.boot.order.entity.ProductInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ProductInfoMapper extends BaseMapper<ProductInfo> {
    ProductInfo getProductInfoByProductId(String productId);

    int reduceProductInventory(@Param("productId") String productId, @Param("count") Integer count);

    ProductInfo getProductInfoByProductIdPessimismLock(String productId);

    int reduceProductInventoryOptimismLock(@Param("productId") String productId, @Param("count") Integer count,
                                           @Param("version") Integer version);
}